package com.sz.youban.controller.info;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineFactory;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.sz.youban.controller.base.BaseController;
import com.sz.youban.dt.entity.result.ResultModel;
@RestController
@RequestMapping("/info")
public class AppInfoController extends BaseController
{
	/**
	 * @return
	 * ,consumes="application/json" 表明必须使用json格式进行数据传送
	 */
	@GetMapping(value="saveAppInfo")//,consumes="application/json")
    public ResultModel saveAppInfo() 
	{
		ScriptEngineManager engineManger = new ScriptEngineManager();
		for(ScriptEngineFactory item : engineManger.getEngineFactories())
		{
			System.out.println(item.getEngineName());
		}
		ScriptEngine engine = engineManger.getEngineByName("groovy");
		String rs = "aaa";
		try {
			rs = (String)engine.eval("def str ='=======hello'");
		} catch (ScriptException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        return success(rs);
    }
}
